package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AutoFillAnnotation;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {

    /**
     * 根据分类id查询套餐的数量
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);
/**插入新套餐*/
    @AutoFillAnnotation
    void insertSetmeal(Setmeal setmeal);

    /**套餐分页查询*/
    Page<SetmealVO> selectSetmealPage(String name, Integer categoryId, Integer status);

    /**套餐状态修改*/
    @Update("update setmeal set status = #{status} where id = #{id}")
    void updateSetmealStatus(Integer status, Long id);

    /**根据id查询套餐*/
    @Select("select * from setmeal where id = #{id}")
    Setmeal selectSetmealById(Long id);

    /**更新套餐*/
    @AutoFillAnnotation(OperationType.UPDATE)
    void updateSetmeal(Setmeal setmeal);

/**根据ids删除套餐*/
    void deleteSetmealByIds(List<Long> ids);

    /**根据ids查询套餐要删除的状态信息*/
    List<Setmeal> selectSetmealByIds(List<Long> ids);

    /**    //判断要启售的套餐中是否存在未启售的菜品*/
     List<Integer> selectStatusByIds(List<Integer> ids);



    /**
     * 动态条件查询套餐
     *
     */
    @Select("select * from setmeal where category_id = #{categoryId} and status = #{status}")
    List<Setmeal> listSetmeal(@Param("categoryId") Long categoryId, @Param("status") Integer status);


    /**
     * 根据套餐id查询菜品选项
     * @param setmealId
     * @return
     */

    List<DishItemVO> getDishItemBySetmealId(Long setmealId);


    /**
     * 根据条件统计套餐数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
